import { TbOrder } from '../../entities/TbOrder';

// 对返回数据进行加工处理
export class OrderDetailResponse {
  id: number;
  orderNo: string;
  userAddress: string;
  sellerAddress: string;
  assetAddress: string;
  assetType: number;
  payAmount: string;
  createdAt: Date;

  constructor(data: TbOrder) {
    if (!data) {
      return null;
    }
    this.id = data.id;
    this.orderNo = data.orderNo;
    this.userAddress = data.userAddress;
    this.sellerAddress = data.sellerAddress;
    this.assetAddress = data.assetAddress;
    this.assetType = data.assetType;
    this.payAmount = data.payAmount;
    this.createdAt = data.createdAt;
  }
}

export interface OrderDataRow {
  id: number;
  orderNo: string;
  userAddress: string;
  sellerAddress: string;
  assetAddress: string;
  assetType: number;
  payAmount: string;
  createdAt: Date;
}

export class OrderListResponse {
  list: OrderDataRow[];

  constructor(dataList: TbOrder[]) {
    if (!dataList) {
      return null;
    }
    this.list = [];
    for (const data of dataList) {
      let tmp: OrderDataRow = {
        id: data.id,
        orderNo: data.orderNo,
        userAddress: data.userAddress,
        sellerAddress: data.sellerAddress,
        assetAddress: data.assetAddress,
        assetType: data.assetType,
        payAmount: data.payAmount,
        createdAt: data.createdAt,
      };
      this.list.push(tmp);
    }
  }
}
